<template>
  <div>
    <el-dialog
      title=""
      :visible.sync="dialogVisible"
      width="40%"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      @close="resetForm"
    >
      <el-descriptions
        title="详细信息"
        :column="2"
      >
        <el-descriptions-item label="方案名称">{{ ruleForm.name }}</el-descriptions-item>
        <el-descriptions-item label="状态">
          <el-tag
            :type="ruleForm.calculate === 1 ? 'success' : 'danger'"
            size="mini"
          >
            {{ ruleForm.calculate === 1 ? '正常' : '禁用' }}
          </el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="峰时间段">
          <template v-for="item in ruleForm.feng">
            <el-tag v-if="item.begin" :key="item.id" type="info" size="mini">{{ item.begin }} - {{ item.end }}</el-tag>
          </template>
        </el-descriptions-item>
        <el-descriptions-item label="平时间段">
          <template v-for="item in ruleForm.ping">
            <el-tag v-if="item.begin" :key="item.id" type="info" size="mini">{{ item.begin }} - {{ item.end }}</el-tag>
          </template>
        </el-descriptions-item>
        <el-descriptions-item label="谷时间段">
          <template v-for="item in ruleForm.gu">
            <el-tag v-if="item.begin" :key="item.id" type="info" size="mini">{{ item.begin }} - {{ item.end }}</el-tag>
          </template>
        </el-descriptions-item>
        <el-descriptions-item label="尖时间段">
          <template v-for="item in ruleForm.jian">
            <el-tag v-if="item.begin" :key="item.id" type="info" size="mini">{{ item.begin }} - {{ item.end }}</el-tag>
          </template>
        </el-descriptions-item>
        <el-descriptions-item label="峰电价(元)">{{ ruleForm.feng_price }}</el-descriptions-item>
        <el-descriptions-item label="平电价(元)">{{ ruleForm.ping_price }}</el-descriptions-item>
        <el-descriptions-item label="谷电价(元)">{{ ruleForm.gu_price }}</el-descriptions-item>
        <el-descriptions-item label="尖电价(元)">{{ ruleForm.jian_price }}</el-descriptions-item>
        <el-descriptions-item label="站点需量(kVA)">{{ ruleForm.station_demand }}</el-descriptions-item>
        <el-descriptions-item label="需量电价(元)">{{ ruleForm.demand_price }}</el-descriptions-item>
        <el-descriptions-item label="站点容量(kVA)">{{ ruleForm.station_capacity }}</el-descriptions-item>
        <el-descriptions-item label="容量电价(元)">{{ ruleForm.capacity_price }}</el-descriptions-item>
      </el-descriptions>
      <div style="display: flex;justify-content: flex-end">
        <el-button type="primary" @click="resetForm">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { detailQuote } from '@/api/fileManage'

export default {
  name: 'info',
  props: {
    id: {
      type: Number,
      default: 0
    },
    dialogVisible: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      optionsType: [],
      optionsSite: [],
      ruleForm: {}
    }
  },
  created() {
    this.getDetailById(this.id)
  },
  methods: {
    // 获取详情
    getDetailById(id) {
      detailQuote({ id }).then(res => {
        this.ruleForm = res.data
      })
    },
    // 表单重置
    resetForm() {
      this.$emit('close')
    }
  }
}
</script>

<style scoped>

</style>
